#include <QtGui>
#include <QtOpenGL>

#include <iostream>
#include <cmath>

#include "glgraphic.h"

GLGraphic::GLGraphic(QWidget *parent) : QGLWidget(parent){
}

GLGraphic::~GLGraphic(){
}
/*
QSize GLGraphic::minimumSizeHint() const{
	return QSize(150, 50);
}

QSize GLGraphic::sizeHint() const{
	return QSize(700, 450);
}*/

void GLGraphic::initializeGL(){
	glClearColor(0.0, 0.0, 0.0, 1.0);
// 	glShadeModel(GL_FLAT);
// 	glEnable(GL_DEPTH_TEST);
// 	glEnable(GL_CULL_FACE);
}

void GLGraphic::paintGL(){
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	//if (system != NULL) system->draw();
}

void GLGraphic::resizeGL(int _width, int _height){
	glViewport(0, 0, _width, _height);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	if (_width<=_height)
		gluOrtho2D(0.0, 2.0, 0.0*((double)_height)/_width, 2.0*((double)_height)/_width);
	else
		gluOrtho2D(0.0*((double)_width)/_height, 2.0*((double)_width)/_height, -0.0, 2.0);

	glMatrixMode(GL_MODELVIEW);
}
